//
//  BaseTableViewController.swift
//  我的微博
//
//  Created by Creator on 15/10/8.
//  Copyright © 2015年 Creator. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {

    
    // 用户登录记录
    var userLogon = UserAccount.userLogon
//    var userLogon = false

    ///  访客视图
    var visitorView: VisitorLoginView?



    override func loadView() {
        // 根据用户是否登录来判断替换根视图
        userLogon ? super.loadView() : setupVisitorView()
    
    }
    
    // 设置访客视图
    private func setupVisitorView() {
        
        visitorView = VisitorLoginView()
        view = visitorView
        visitorView?.delegte = self
        
        // 导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")

    }
    
    // MARK: - VisitorLoginViewDelegate 的代理方法
    
    func visitorLoginViewWillLogin() {
        
        let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    func visitorLoginViewWillRegister() {
        print("注册")
    }
}





